import { Module } from '@nestjs/common';
import { PrismaModule } from './prisma/prisma.module';
import { UserModule } from './user/user.module';
import { RedisModule } from './redis/redis.module';
import { EmailModule } from './email/email.module';
import { JwtModule } from '@nestjs/jwt';
import { APP_GUARD } from '@nestjs/core';
import { AuthGuard } from './guard/auth.guard';
import { FriendshipModule } from './friendship/friendship.module';
import { ChatroomModule } from './chatroom/chatroom.module';
import { ChatModule } from './chat/chat.module';
import { ChatHistoryModule } from './chat-history/chat-history.module';


@Module({
    imports: [
        PrismaModule, 
        UserModule, 
        RedisModule, 
        EmailModule, 
        JwtModule.registerAsync({
            global: true,
            useFactory() {
                return {
                    secret: 'lrq_secret_v1',
                    signOptions: {
                        expiresIn: '30m', // 默认 30 分钟
                    },
                };
            },
        }), FriendshipModule, ChatroomModule, ChatModule, ChatHistoryModule,
    ],
    providers:[
        {
            provide: APP_GUARD,
            useClass: AuthGuard
        }
    ]
})
export class AppModule { }
